package org.example.controller;


import org.example.Order;
import org.example.ResultMap;
import org.example.service.OrderFeignService;
import org.example.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RefreshScope //@RefreshScope动态刷新配置实现原理
@RestController
@RequestMapping("order")
public class OrderController {

    @Value("${config.name}")
    public String config;

    @RequestMapping("configTest")
    public String configTest() {
        return config;
    }

    @Autowired
    OrderService orderService;
    @Autowired
    OrderFeignService orderFeignService;

    @RequestMapping("addOrder")
    public ResultMap addOrder(@RequestBody Order order) {
        ResultMap resultMap = new ResultMap();
        orderService.addOrder(order);
        orderFeignService.updateInventory(order);
        return resultMap;
    }


}
